home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 193_01 / cypher1.c < prev    next >
Text File  |  1985-11-13  |  640b  |  32 lines

  1. /*    cypher1.c    Cypher module        by F.A.Scacchitti
  2. **                            10/10/85
  3. **
  4. **    Simple cypher module - encodes directly with user keys
  5. **
  6. */
  7.  
  8. #include <stdio.h>
  9.  
  10. static int i, n, keylength;
  11.  
  12. cypher1(buffer, num, code) char *buffer, *code; int num;{
  13.  
  14. /*
  15. ** get keylength for each key
  16. */
  17.  
  18.    keylength = 0;
  19.    while(code[keylength++] != NULL);
  20.    keylength--;
  21.  
  22. /*
  23. ** encrypt the file with each key
  24. */
  25.  
  26.    printf("-encoding/decoding buffer\n");
  27.  
  28.    for(i=0; i<=num; i++)
  29.       buffer[i] = buffer[i] ^ code[i % keylength];
  30. }
  31.  
  32.